﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GameManager : MonoBehaviour {
	public static GameManager _instance;
	private Text scoreText;
	// Use this for initialization
	private int score = 0;
	private bool isPause = false;
	private AudioSource audioSource;
	public Image pauseBtn;
	public Sprite continueSp;
	public Sprite pauseSp;

	void Awake (){
		_instance = this;	
	}

	void Start () {
		scoreText = GameObject.FindGameObjectWithTag ("ScoreText").GetComponent<Text>();
		audioSource = gameObject.GetComponent<AudioSource> ();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	//加分数
	void addScore(int score){
		this.score += score;
		scoreText.text = "Score:"+this.score.ToString();
	}

	public static GameManager getInstance(){
		return _instance;
	}
	//暂停游戏
	public void pauseGame (){
		print ("pause game");
		if (isPause) {
			Time.timeScale = 1;
			audioSource.UnPause ();
			pauseBtn.sprite = pauseSp;
		} else {
			Time.timeScale = 0;
			audioSource.Pause ();
			pauseBtn.sprite = continueSp;
		}
		isPause = !isPause;
	}
	//返回游戏状态
	public bool getGameStatus(){
		return isPause;
	}
}
